package com.klun.designMode.composite.modeOne;

public class ModeOneTest {
	public static void main(String[] args) {
		// 生成树根，并为其增加两个叶子节点
		Component root =  new Composite("Root");
		root.add(new Leaf("leaf a in root"));
		root.add(new Leaf("leaf b in root"));
		root.add(new Leaf("leaf c in root"));

		// 为根增加两个枝节点
		Component branchX = new Composite("branch a in root");
		Component branchY = new Composite("branch b in root");
		root.add(branchX);
		root.add(branchY);

		// 为BranchX增加页节点
		branchX.add(new Leaf("Leaf A in Branch X"));

		// 为BranchX增加枝节点
		Component branchZ = new Composite("Branch Z in Branch X");
		branchX.add(branchZ);

		// 为BranchY增加叶节点
		branchY.add(new Leaf("Leaf in Branch Y"));

		// 为BranchZ增加叶节点
		branchZ.add(new Leaf("Leaf in Branch Z"));

		// 显示树
		root.operation();

	}
}
